// import {} from '@/request/index/index.js'
const Tool = {
	// getUpToken:() => {
	// 	return new Promise((resolve, reject) => {
	// 		store.dispatch('api/getUpToken').then(res => {
	// 			resolve(res)
	// 		})
	// 	})
	// },
	/**
	 * @上传图片
	 */
	uploadFile: async  function({
		formData = {},
		filePath,
		url = `https://up-z1.qiniup.com`,
		header = {}
	} = {}) {
		let Up = await this.getUpToken();
		formData['key'] = Up['key'];
		formData['token'] = Up['uptoken'];
		return new Promise((resolve, erject) => {
			// 单图上传
			if (filePath.length <= 1) {
				uni.uploadFile({
					url,
					filePath: filePath[0],
					name: 'file',
					formData,
					header,
					success: uploadFileRes => {
						resolve(JSON.parse(uploadFileRes.data))
					},
					fail: err => {
	
					}
				});
			} else {
				// 多图上传
				let imgs = [];
				for (let i = 0; i < filePath.length; i++) {
					uni.uploadFile({
						url,
						filePath: filePath[i],
						name: 'file',
						formData,
						header,
						success: uploadFileRes => {
							let img = JSON.parse(uploadFileRes.data).data;
							imgs.push(img);
							if (i === filePath.length - 1) {
								console.log('完成');
								resolve(imgs)
							};
						},
						fail: err => {
							erject(err)
						}
					});
				}
			}
		})
	},
	
	/**
	 * @手机号格式化方法
	 */
	phone:function(phone){
		let s = 3;
		let e = 7;
		phone = phone.split('');
		console.log(phone.map(item=>{ 
			if(item >= s && item<= e){
				item = '*';
			}
			return item;
		}));
		// for(let i = 0; i<phone['length'];i++){
		// 	if(i >= s && <= e){
				
		// 	}
		// }
		return 
	}
	
}
export default Tool